home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / include / polyint.h < prev    next >
C/C++ Source or Header  |  1992-10-22  |  5KB  |  115 lines

  1. #ifndef POLYINT_H
  2. #define POLYINT_H
  3.  
  4. /*
  5.  * Tolerance - a good value to pass to PolyZInt and its subsidieries.
  6.  */
  7. #define POLYINT_TOL 1.e-6
  8.  
  9. /*
  10.  * PolyZInt
  11.  * Finds intersection of z-axis and arbitrary flat polygon.
  12.  *
  13.  * Input:
  14.  * n_verts          # of vertices in polygon (the length of the verts array)
  15.  * verts            vertices of polygon
  16.  * tol              Tolerance.  Any point whose distance from the z-axis 
  17.  *                  is less than tol will be considered hit.
  18.  *
  19.  * Output:
  20.  * All output values are vvecs (See ooglutil.h).  They must already be 
  21.  * initialized when passed to PolyZInt.  Any new intersection points found
  22.  * by PolyZInt will be appended onto the vvec.  The count field of all the 
  23.  * vvecs must be up to date.  When PolyZInt returns, this field will reflect
  24.  * any new elements that have been added to the vvec (ie, the new count 
  25.  * field will be equal to the old count field plus the number of intersection
  26.  * points found by PolyZInt).  Note that all the vvecs will be the same 
  27.  * length.  PolyZInt will return the number of intersection points found.
  28.  * ip               Intersection points (Point3).  These are the points where
  29.  *                  the Z-axis intersects the plane containing the polygon.
  30.  *                  Note that if tol > 0.0, these points may not actually
  31.  *                  be inside the polygon.
  32.  * vertices         Vertex intersections (ints - indices into verts).  If no
  33.  *                  vertex intersection was found, the corresponding element
  34.  *                  in this vvec will be set to -1.
  35.  * edges            Edge intersections (ints - indices of first point in
  36.  *                  verts list).  If no edge intersection was found, the 
  37.  *                  corresponding element in this vvec will be set to -1.
  38.  * ep               Edge intersection locations, if any were found (Point3).
  39.  *                  An element of this array will contain valid data iff
  40.  *                  the corresponding element of the edges vvec is not equal
  41.  *                  to -1.  The elements of this are guarenteed to be points
  42.  *                  on the edge, but, because of the tolerance, may not be
  43.  *                  equal to the corresponding elements of the ip array.
  44.  * For every intersection point found, ip will be filled in.  vertices will
  45.  * be filled in only if a vertices was within tol of the intersection point.
  46.  * If a vertices was within tol of the intersection point, the edges to which
  47.  * the point belongs will not be considered to have been hit.
  48.  */
  49. int PolyZInt(int n_verts, Point3 *verts, float tol, 
  50.          vvec *ip, vvec *vertices, vvec *edges, vvec *ep);
  51.  
  52. /* 
  53.  * PolyNearNegZInt
  54.  * Wrapper for PolyZInt designed for mouse picking.  Finds the 
  55.  * intersection closest to the origin on the positive Z axis.
  56.  * Returns non-zero if there was a hit.
  57.  *
  58.  * Input:
  59.  *         (See above)
  60.  * Output:
  61.  * ip        Intersection point.
  62.  * vertex    Index of vertex or -1 if there was no vertex hit.
  63.  * edge        Index of first vertex of edge or -1 if there was no 
  64.  *         edge hit.
  65.  * ep        Edge point.
  66.  */
  67. int PolyNearPosZInt(int n_verts, Point3 *verts, float tol,
  68.             Point3 *ip, int *vertex, int *edge, Point3 *ep);
  69.  
  70. /* 
  71.  * PolyLineInt
  72.  * Finds intersection of arbitrary line and arbitrary flat polygon.
  73.  * pt1              One point on the line
  74.  * pt2              A different point on the line
  75.  * Other arguements as above
  76.  */
  77. int PolyLineInt(Point3 *pt1, Point3 *pt2, int n_verts, Point3 *vert, 
  78.         float tol, vvec *ip, vvec *vertices, vvec *edges, vvec *ep);
  79.  
  80. /* 
  81.  * PolyRayInt
  82.  * Finds intersection of an arbitrary ray and an arbitrary flat polygon.
  83.  * The endpoint is included.
  84.  * pt1              Endpoint of the ray
  85.  * pt2              A different point on the ray
  86.  * Other arguements as above
  87.  */
  88. int PolyRayInt(Point3 *pt1, Point3 *pt2, int n_verts, Point3 *verts, 
  89.            float tol, vvec *ip, vvec *vertices, vvec *edges, vvec *ep);
  90.  
  91. /*
  92.  * PolySegmentInt
  93.  * Finds the intersection of an arbitrary segment and an arbitrary flat
  94.  * polygon.  The endpoints are included.
  95.  * pt1              One endpoint of the segment
  96.  * pt2              The other endpoint of the segment
  97.  * Other arguements as above
  98.  */
  99. int PolySegmentInt(Point3 *pt1, Point3 *pt2, int n_verts, Point3 *verts, 
  100.            float tol, vvec *ip, vvec *vertices, vvec *edges, vvec *ep);
  101.  
  102.  
  103. /*
  104.  * PolyInt_Align
  105.  * Creates a coordinate system such that the first specified point becomes
  106.  * the origin and the second becomes (0, 0, -1)
  107.  * pt1              Point which will map to the origin
  108.  * pt2              Point which will map to (0, 0, -1)
  109.  * T                Matrex in which the transformation will be placed
  110.  */
  111. void PolyInt_Align(Point3 *pt1, Point3 *pt2, Transform T);
  112.  
  113. #endif /* POLYINT_H */
  114.  
  115.